
/**
 * 参数
 */
var Param = {
    CMDKEY: 'cmd',// command key
    CMDTYPEKEY: 'cmdType',// command type key
    CMDVALUEKEY: 'cmdValue',// command value key
    PARAMJSONKEY: 'paramJson',// param json key
    EXCELEXPIDKEY: 'rns',// excel export param json id key
    CREATE: 1,// 新增/添加
    READ: 2,// 查询
    UPDATE: 3,// 修改/编辑/更新
    DELETE: 4,// 删除/移除
    LOAD: 5,// 加载
    EXPORT: 6,// 导出
    IMPORT: 7,// 导入
    // 分页相关
    PAGE: 'page',
    PAGE_SIZE: 'pageSize',
    SORT_FIELD: 'sortField',
    SORT_DIRECTION: 'sortDirection',


    /**
     * 获取command key
     * @returns
     */
    getCmdKey: function(){
        return this.CMDKEY;
    },
    /**
     * 获取create command
     * @returns
     */
    getCreateCmd: function(){
        var cmd = {};
        cmd[this.CMDKEY] = this.CREATE;
        return cmd;
    },
    /**
     * 获取read command
     * @returns
     */
    getReadCmd: function(){
        var cmd = {};
        cmd[this.CMDKEY] = this.READ;
        return cmd;
    },
    /**
     * 获取update command
     * @returns
     */
    getUpdateCmd: function(){
        var cmd = {};
        cmd[this.CMDKEY] = this.UPDATE;
        return cmd;
    },
    /**
     * 获取delete command
     * @returns
     */
    getDeleteCmd: function(){
        var cmd = {};
        cmd[this.CMDKEY] = this.DELETE;
        return cmd;
    },
    /**
     * 获取load command
     * @returns
     */
    getLoadCmd: function() {
        var cmd = {};
        cmd[this.CMDKEY] = this.LOAD;
        return cmd;
    },
    /**
     * 获取export command
     * @returns
     */
    getExportCmd: function() {
        var cmd = {};
        cmd[this.CMDKEY] = this.EXPORT;
        return cmd;
    },
    /**
     * 获取import command
     * @returns
     */
    getImportCmd: function() {
        var cmd = {};
        cmd[this.CMDKEY] = this.IMPORT;
        return cmd;
    },

    /**
     * 构建后端需要格式的参数
     * @param param 参数对象
     * @param cdt 值
     * @returns
     */
    buildParam: function(param, cdt){
        param[this.PARAMJSONKEY] = JSON.stringify(cdt);
        return param;
    },
    /**
     * 构建分页参数
     * @param param
     * @param page
     * @param pageSize
     */
    buildPagingParam: function(param, page, pageSize){
        param[Param.PAGE] = page;
        if(!pageSize){
            pageSize = 30;
        }
        param[Param.PAGE_SIZE] = pageSize;
        return param;
    },


};
